 <?php
  if(isset($this->mess)){
        if($this->flag == 'success')
            echo '<div style="width: 75%;float: right;" class="alert alert-success" role="alert">',$this->mess,'</div>';
        elseif($this->flag == 'alert')
            echo '<div style="width: 75%;float: right;" class="alert alert-warning" role="alert">',$this->mess,'</div>';
        else
            echo '<div style="width: 75%;float: right;" class="alert alert-danger" role="alert">',$this->mess,'</div>';
  }else{ ?>
    <?php
    $this->headTitle('Làm mới tin','append');
    switch(strlen($this->proCheck['mobile'])) {        
    case 10:
        $this->proCheck['mobile'] = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "$1 $2 $3", $this->proCheck['mobile']);
        break;
    case 11:
        $this->proCheck['mobile'] = preg_replace("/([0-9]{4})([0-9]{4})([0-9]{3})/", "$1 $2 $3", $this->proCheck['mobile']);
        break;
    default:        
        break;
    }
?>
<div class="col-md-9">
    <div class="mycontent maket-post">    
        <div class="navi">
            <?php echo $this->navi;?>                    
        </div>
        <h2>Làm mới tin</h2>                
        <button class="btn btn-warning btn-circle btn-lg shape">1</button>
            <label>&nbsp; Đưa lên top &raquo;&nbsp;</label>
        <button class="btn btn-success btn-circle btn-lg shape">2</button>
            <label>&nbsp; XONG!</label>
        <h2>Nội dung tin đăng</h2>
                
        <div class="block block-review">
            <div class="legend">
                <label>Thông tin cơ bản</label>
            </div>            
            <div class="col-md-3">
                <label>Bạn là:</label>
            </div>
            <div class="col-md-3">
                <p><?php echo $this->proCheck['human']?></p>                          
            </div>
            <div class="col-md-3">
                <label>Giao dịch: </label>
            </div>
            <div class="col-md-3">
                <p><?php echo $this->proCheck['transaction']?></p>      
            </div>
            <div class="col-md-3">
                <label>Khu vực:</label>
            </div>
            <div class="col-md-9">
                <p><?php echo $this->proCheck['areaName']?></p>
            </div>                
            <div class="col-md-3">
                <label>Danh mục:</label>                     
            </div>
            <div class="col-md-9">
                <p><?php echo $this->proCheck['catName']?> &nbsp;&gt;&gt;&nbsp; <?php echo $this->proCheck['itemName']?></p>
            </div>
            <div class="col-md-3">
                <?php echo (isset($this->proCheck['startDate']))?'<label>Ngày bắt đầu đăng tin:</label>':'';?>                     
            </div>
            <div class="col-md-9">
                <?php echo (isset($this->proCheck['startDate']))?'<p>'.date('Y-m-d',$this->proCheck['startDate']).'</p>':'';?>
            </div>                        
            <div class="col-md-3">
                <?php echo (isset($this->proCheck['endDate']))?'<label>Ngày kết thúc:</label>':'';?>                     
            </div>            
            <div class="col-md-3">                
                <?php echo (isset($this->proCheck['endDate']))?'<p>'.date('Y-m-d',$this->proCheck['endDate']).'</p>':'';?>                                   
            </div>
            <div class="col-md-3">
                Phí lên top:                     
            </div>            
            <div class="col-md-3">                
                <p style="color: red;"><?php echo number_format($this->priceTop,0,'.',',') ?>  VNĐ  </p>                            
            </div>
            <div class="col-md-6">
                &nbsp;                     
            </div>
            <div class="col-md-3">
                &nbsp;                     
            </div>
            <div class="col-md-9 reminder">
                                     
            </div>            
            <div class="clearfix"></div>
                           
        </div>
        <div class="block block-review">
            <div class="legend">
                <label>Nội dung tin đăng</label>
            </div>
            <h3><?php echo $this->proCheck['title']?></h3>
            <p><?php echo $this->proCheck['content']?></p>
            <div class="block image" style="text-align: center;">
                <div class="legend">
                    <label>Hình ảnh</label>
                </div>
            </div> 
            <div class="col-md-2">
                <label>Giá:</label>
            </div>
            <div class="col-md-10">
                <p><?php echo number_format($this->proCheck['price'],0,'.',',')?> VNĐ</p>
            </div>           
            <div class="clearfix"></div>                        
        </div>    
        <div class="block block-review">
            <div class="legend">
                <label>Thông tin liên hệ</label>
            </div>
            <div class="col-md-2">
                <label>Người liên hệ:</label>
            </div>
            <div class="col-md-10">
                <p><?php echo $this->proCheck['contact']?>&nbsp;</p>
            </div>
            <div class="col-md-2">
                <label>Số di động:</label>
            </div>
            <div class="col-md-10">
                <p><?php echo $this->proCheck['mobile']?>&nbsp;</p>
            </div>
            <div class="col-md-2">
                <label>Email liên hệ:</label>
            </div>
            <div class="col-md-10">
                <p><?php echo $this->proCheck['emailCont']?>&nbsp;</p>
            </div>
            <div class="col-md-2">                                                
                <label>Địa chỉ liên hệ:</label>
            </div>
            <div class="col-md-10">                                                
                <p><?php echo $this->proCheck['addressCont']?>&nbsp;</p>                
            </div>            
            <div class="clearfix"></div>
        </div>                
        <div class="col-md-12">
            <center>
                 <form class="form-inline" action="product/top" method="post" style="margin-bottom:20px;">
                    <input type="hidden" name="id" value="<?php echo $this->proCheck['id']?>"/>                                        
                    <button style="width:150px;background-color:ForestGreen;" id="submitbutton" name="direc" value="submit" type="submit" class="form-control">Đồng ý</button>
                    <button style="width:150px;background-color:FireBrick;" name="direc" value="cancel" type="cancel" class="form-control">Huỷ</button>                    
                 </form>
            </center>
        </div>                          
    </div>
</div>
<?php    
    $image = json_decode($this->proCheck['photo']);
    $configPrice = new Zend_Config_Ini(CONFIG_PATH.'/price.ini', APPLICATION_ENV);
    $price=$configPrice->price->toArray();
    //pr($this->userCheck['gold']);               
?>
<script type="text/javascript">    
    <?php
        $i=0;                            
        foreach($image as $k => $v){
    ?>            
            $(".image").append(
                '<img id="photo-<?=$i?>" src="<?=$v?>" onerror="this.onerror=null;this.src=\'/public/static/images/noimage.jpg\';"/>'                
            );    
    <?php
            $i++;
        }        
    ?>    
</script>
<script type="text/javascript">           			
    function daydiff(first, second) {
    	return (second-first)/(1000*60*60*24)		
	}
    function numberWithCommas(x) {
        x = x.toString(); var pattern = /(-?\d+)(\d{3})/; while (pattern.test(x))
        x = x.replace(pattern, "$1,$2"); return x;
    }                
    var mindate = new Date();        
    mindate.setDate(mindate.getDate()+1);        
    var minDate = mindate.getFullYear()+'/'+parseInt(mindate.getMonth()+1)+'/'+mindate.getDate();                          
    $(".mydatepicker").datetimepicker({        
        format: "Y-m-d H:i",
        lang:'vi',
        i18n:{
          vi:{
           months:[
            'Tháng 1','Tháng 2','Tháng 3','Tháng 4',
            'Tháng 5','Tháng 6','Tháng 7','Tháng 8',
            'Tháng 9','Tháng 10','Tháng 11','Tháng 12',
           ],
           dayOfWeek:[
            "CN", "T2", "T3", "T4", 
            "T5", "T6", "T7",
           ]
          }
         },
        yearStart:"2010",
        yearEnd:"2020",
        timepicker:false,           
        minDate:mindate,              
    });                                            
    $(document).ready(function(){
      
        $('#submitbutton').click(function(){
            if(  <?php echo $this->userCheck['gold'] ?> < 1000 ){
                alert('Phí lên top vượt quá số tiền trong tài khoản. Vui lòng nạp tiền để thực hiện chức năng này!');
                return false;
            }                                                                                                      
        });                                 
    });    				
</script>
<?php } ?>